home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Codigo / Control del teclado / ExitOnX / ExitOnX.cs next >
Encoding:
Text File  |  2002-04-24  |  613 b   |  26 lines

  1. //--------------------------------------
  2. // ExitOnX.cs ⌐ 2001 by Charles Petzold
  3. //--------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class ExitOnX: Form
  9. {
  10.      public static void Main()
  11.      {
  12.           Application.Run(new ExitOnX());
  13.      }
  14.      public ExitOnX()
  15.      {
  16.           Text = "Salir con X";
  17.           BackColor = SystemColors.Window;
  18.           ForeColor = SystemColors.WindowText;
  19.      }
  20.      protected override void OnKeyDown(KeyEventArgs kea)
  21.      {
  22.           if (kea.KeyCode == Keys.X)
  23.                Close();
  24.      }
  25. }
  26.